package cool.webstudy.admin.constant.enums.rescode;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 莫振双
 * @date 2025/2/23 12:10
 * @description: 文件相关响应码枚举
 */
@Slf4j
public enum FileResCodeEnum implements BaseResCodeEnum{
    RC_ERROR_UPLOAD("140001","文件上传失败"),
    RC_ERROR_FILE_MISS("140002","文件对象缺失"),
    RC_ERROR_CREATE_DIR("140003","创建文件目录失败"),
    RC_ERROR_GET_FILE_SUFFIX("140004","获取文件后缀名失败"),
    RC_ERROR_GET_FILE_NAME("140005","获取文件名称失败"),
    RC_ERROR_CREATE_FILE("140006","创建文件失败"),
    RC_ERROR_CREATE_FILE_RECORD("140007","创建文件记录信息失败"),
    RC_ERROR_QUERY_FILE("140008","查询文件失败"),
    RC_ERROR_QUERY_FILE_NOT_EXIST("140009","查询文件不存在"),
    RC_ERROR_QUERY_FILE_PARAM_MISS("140010","查询文件记录参数缺失"),
    RC_ERROR_UPDATE_FILE_PARAM_MISS("140011","更新文件记录参数缺失"),
    RC_ERROR_UPDATE_FILE_RECORD("140012","更新文件记录失败"),
    RC_ERROR_DELETE_FILE_RECORD_PARAM_MISS("140013","删除文件记录参数缺失"),
    RC_ERROR_DELETE_FILE_RECORD("140014","删除文件记录失败"),
    RC_ERROR_QUERY_FILE_RECORD_PARAM_MISS("140015","查询文件记录参数缺失"),
    RC_ERROR_QUERY_FILE_LIST_RECORD( "140016","查询文件记录列表失败")
    ;
    String code;
    String msg;
    FileResCodeEnum(String code, String msg){
        this.code = code;
        this.msg = msg;
    }
    @Override
    public String code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }
    public static FileResCodeEnum getMsgByCode(String code){
        for (FileResCodeEnum resCodeEnum : FileResCodeEnum.values()) {
            if (resCodeEnum.code().equals(code)){
                return resCodeEnum;
            }
        }
        log.error("getMsgByCode 无法获取枚举值");
        return null;
    }
}
